package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.MallRankingListPool;
import com.sc.nft.mapper.MallRankingListPoolMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

/**
 * 排行榜奖池
 */
@Slf4j
@Repository
public class MallRankingListPoolDao extends ServiceImpl<MallRankingListPoolMapper, MallRankingListPool> {

    public MallRankingListPool getResidualPrizePool() {
        LambdaQueryWrapper<MallRankingListPool> wrapper = new LambdaQueryWrapper<>();
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }

    public Boolean subAmount(BigDecimal initPoolReserve,Long id) {
        return baseMapper.subAmount(id,initPoolReserve);
    }

    public Boolean addAmount(BigDecimal initPoolReserve, Long id) {
        return baseMapper.addAmount(id,initPoolReserve);
    }

    public void subFreezeAmount(BigDecimal subFreezeAmount, Long id) {
        baseMapper.subFreezeAmount(id,subFreezeAmount);
    }
}